package com.pucong.gitee.database.backup.common.selfenum;

import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel("数据库版本枚举类")
public enum DatabaseVersionEnum implements CommonEnum<Integer> {

    oracle10c(0, "oracle"),
    sqlserver(1, "sqlserver"),
    mysql56(2, "mysql"),
    postgresql(3, "postgresql");

    @ApiModelProperty(value = "key",example = "0")
    private Integer key;

    @ApiModelProperty("描述")
    private String desc;

    DatabaseVersionEnum(Integer key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    /**
     * 字典code
     *
     * @return
     */
    @Override
    public Integer getValue() {
        return this.key;
    }

    /**
     * 字典名称
     *
     * @return
     */
    @Override
    public String getName() {
        return this.name();
    }

    @JsonCreator
    public static DatabaseVersionEnum findEnumByValue(Integer value){
        for (DatabaseVersionEnum item : DatabaseVersionEnum.values()) {
            if (item.getValue().equals(value)) {
                return item;
            }
        }
        return null;
    }
}